# -*- coding: utf-8 -*-
"""
Created on Mon Sep  4 22:20:35 2017

@author: zhiqiang
"""
import time
st = time.clock()

def findEuler52Ans():
    di_num = 2
    while True:    
        low_limit = 10**(di_num-1)
        up_limit = round(10**di_num/6)
        for i in range(low_limit,up_limit):
            a = list(str(i))
            a.sort()
            equl_num = 0
            for j in range(6,1,-1):
                b = list(str(j*i))
                b.sort()
                if a==b:
                    equl_num += 1
                else:
                    break
            if equl_num==5:
                print(i)
                return i
        di_num += 1

if __name__=="__main__":
    findEuler52Ans()
    
print(time.clock()-st)
                